#!/bin/sh
# PCP QA Test No. 1275
# pmlogger -C checkout ... man page check ... see qa/687 for
# non-man page parts of this test
#
# Copyright (c) 2018,2020 Ken McDonell.  All Rights Reserved.
#

seq=`basename $0`
if [ $# -eq 0 ]
then
    echo "QA output created by $seq"
else
    echo "QA output created by $seq $*"
fi

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

status=0	# success is the default!
$sudo rm -rf $tmp $tmp.* $seq.full
trap "_cleanup; exit \$status" 0 1 2 3 15

# real QA test starts here

TERM=dumb LANG=POSIX LC_MESSAGES=POSIX man pmlogger >$tmp.out 2>$tmp.err
sts=$?
if [ $sts -ne 0 ] || [ ! -s $tmp.out ]
then
    echo "man exit status: $sts:" >>$seq.full
    echo "---stderr ---" >>$seq.full
    cat $tmp.err >>$seq.full
    echo "---stdout ---" >>$seq.full
    cat $tmp.out >>$seq.full
    _notrun "pmlogger man page not installed"
fi

echo "=== should be in man page ==="
sed -n <$tmp.out \
    -e 's/.//g' \
    -e 's/  */ /g' \
    -e '/\[-[^]]*C/{
s//[-...C/
s/C.*/C...] .../
p
}' \
    -e '/The -C option/{
s/configuration file.*/configuration file .../p
}' \
# end

exit
